{% extends "announcements/announcements.html" %}

{% block page_link %}
    <link rel="stylesheet" href="../../static/public_file/css/ApprovalBox.css">
{% endblock %}


{% block style %}
    <style>
        .add_class{
            background: #1E90FF;
        }
        .add_background {
            background: #A9A9A9;
        }
        .top_tag {
            border-bottom: #01AAED solid 2px;color: #01AAED;
        }

        .tab_top {
            width: 110px;height: 40px;line-height: 40px;text-align: left;display: inline-block;cursor: pointer;padding-left: 1%;
        }
        .button_for_control {
            width: 90px;height: 30px;border: 1px solid #99D3F5;background: #D0EEFF;border-radius: 4px;letter-spacing: 0;line-height: 30px;color: #089bab;margin: 5px 0;
        }
    </style>
{% endblock %}


{% block right_content %}
    <div style="width: 100%;height: 40px;background: white;border-bottom: #A9A9A9 solid 0.5px;">
        <div id="DW_tag" class="tab_top top_tag" onclick="change_mind('DW')">
            公告详情
        </div>
        <div id="LH_tag" class="tab_top" onclick="change_mind('LH')">
            附件
        </div>
        <div id="lct_tag" class="tab_top" onclick="change_mind('lct')">
            流程图
        </div>

        <div id="" style="width: 100px;float: right;text-align: center;margin-right: 1%;height: 40px;">
            <button id="" onmousemove="page_zhanshi()" onmouseout="page_yincang()"
                    style="width: 100px;height: 30px;line-height: 27px;border: #1E90FF solid 1px;background: #1E90FF;color: white;margin-top: 5px;border-radius: 3px;">
                操作
            </button>
        </div>

        <!-- 操作按钮隐藏块 -->
        <div id="page_one" onmousemove="page_zhanshi()" onmouseout="page_yincang()"
             style="z-index: 1000; position: absolute; width: 100px; height: auto;right: 0.9%; top: 80px;background: #FFFFFF; box-shadow: rgb(204 204 204) 2px 2px 10px;padding: 5px;display: none;">
            {% if is_audit == 'true' and is_edit == 'false' %}
                <button id="approve" onclick="online_approval_tag()" class="button_for_control">
                    审批
                </button>
            {% endif %}

            {% if is_stop == 'true' and is_edit == 'false' %}
                <button id="is_stop" onclick="operate_button(this.id)" class="button_for_control">
                    终止
                </button>
            {% endif %}

            {% if is_edit == 'true' %}
                <button id="add_station" type="button" class="button_for_control" onclick="ExportCar()">
                    提交修改
                </button>
            {% endif %}
        </div>
    </div>

    <div id="appave-model" class="approval-shade">
        <div id="examine-model" style="width: 700px;background: white;left: 50%;top: 50%;position: absolute;transform: translate(-50%, -50%);">
            <div id="appave-title" style="width: 100%;height: 40px;border-bottom: #cfcfcf solid 1px;font-size: 14px;cursor: move;">
                <div style="width: 40%;height: 40px;line-height: 40px;text-align: left;padding-left: 1%;letter-spacing: 2px;float: left;">
                    审批
                </div>
                <div style="width: 59%;height: 40px;letter-spacing: 2px;float: left;">
                    <div onclick="close_approval_models()" style="width: 40px;height: 40px;text-align: center;line-height: 40px;cursor: pointer;float: right;">
                        <i class="iconfont icon-quchu"></i>
                    </div>
                </div>
            </div>

            <div style="width: 100%;font-size: 14px;background: #E8E8E8;padding-top: 1%;">
                <div style="width: 98%;margin-left: 1%;background: white;padding-top: 1%;padding-left: 1%;border-radius: 3px;margin-top: 1%;padding-right: 1%;padding-bottom: 20px;">
                    <div style="width: 100%;height: 35px;line-height: 35px;border-bottom: #E8E8E8 solid 1px;padding-left: 1%;">
                        意见
                    </div>
                    {% if trave_obj.state == 'six' %}
                        <div style="margin-top: 3%;width: 100%;">
                            <input type="text" id="ReimbursementAmount" style="width: 96%;height: 30px;border: #cfcfcf solid 1px;margin-left: 2%;" placeholder="请填写实际报销金额">
                        </div>
                    {% endif %}
                    <div style="width: 100%;">
                        <textarea id="opinion_detail" placeholder="请输入审批意见" style="width: 96%;height: 100px;margin-left: 2%;margin-top: 2%;border: #cfcfcf solid 1px;outline: none;font-size: 14px;" ></textarea>
                    </div>
                </div>

                <div style="width: 100%;height: 40px;background: white;margin-top: 1%;text-align: right;padding-right: 2%;">
                    <button onclick="summit_data('audit')" style="letter-spacing: 3px;width: 100px;height: 30px;margin-top: 5px;border-radius: 1px;border: #00a0e9 solid 1px;text-align: center;background: #00a0e9;color: white;">同意</button>
                    <button onclick="summit_data('draft')" style="letter-spacing: 3px;width: 100px;height: 30px;margin-top: 5px;border-radius: 1px;border: #00a0e9 solid 1px;text-align: center;background: #00a0e9;color: white;margin-left: 15px;">退回修改</button>
                </div>
            </div>
        </div>
    </div>

    <div id="DW" style="width: 100%;height: 95%;background: white;overflow: auto;">
        <div id="menu_from"
             style="width: 100%;height: 100%;color: #2C3E50;display: inline-block;vertical-align: top;background: white;">
            <div style="width: 100%;height: 90%;display: inline-block;vertical-align: center;margin-top: 1.5%;">
                <div style="width: 95%;margin-left: 2.5%;">
                    <table style="width: 100%;">
                        <tr>
                            <td colspan="4" style="width: 100%;height: 40px;padding-left: 0.5%;line-height: 40px;border: #cfcfcf solid 1px;text-align: center;">
                                <div style="width: 100%;height: 40px;line-height: 40px;text-align: center;"><h3 id="notice_title">{{ obj.name }}</h3></div>
                                <div style="width: 100%;height: 40px;line-height: 40px;text-align: center;"><span id="company">{{ obj.create_people.company.name }}</span> <span style="margin-left: 2%;" id="create_people">{{ obj.create_people.real_name }}</span></div>
                                <div style="width: 100%;height: 40px;line-height: 40px;text-align: center;" id="creat_time">{{ obj.create_time|date:'Y-m-d H:i' }}</div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4" style="width: 100%;height: 40px;padding-left: 0.5%;line-height: 40px;border: #cfcfcf solid 1px;padding-left: 20%;padding-right: 20%;">
                                {% autoescape off %}
                                    {{ countent }}
                                {% endautoescape %}
                            </td>
                        </tr>
                    </table>
                </div>
                <div style="width: 95%;margin-left: 2.5%;">
                    <table style="width: 100%;">
                        <tr>
                            <td colspan="2" style="height: 40px;padding-left: 0.5%;line-height: 40px;background: #dfdfdf;border: #cfcfcf solid 0.5px;border-top: none;">
                                审批详情
                            </td>
                        </tr>
                        {% if 'one' in audit_dic %}
                            <tr style="width: 100%;{% if obj.is_leader == True %} display: none{% endif %}">
                                <td style="width: 15%;height: 150px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;letter-spacing: 4px;">
                                    分管领导
                                </td>
                                <td style="width: 85%;height: 150px;border: #cccccc solid 1px;border-left: none;border-top: none;">
                                    {% for k,v in audit_dic.items %}
                                        {% if k == 'one' %}
                                            {% for item in v %}
                                                {% if item.state != 'unaudit' %}
                                                    <div id="fzrcs_op"
                                                         style="width: 100%;line-height: 20px;position: relative;">
                                                        <span>{{ item.state_display }}</span>
                                                        <span style="margin-left: 3%">{{ item.audit_note }}</span>
                                                    </div>
                                                    <div>
                                                        <img src="{{ item.signature_picture }}" alt=""
                                                             style="width: 150px; height: 60px;">
                                                    </div>
                                                    <div style="text-align: right;color: #0b0b0b;">{{ item.audit_time }}</div>
                                                {% endif %}
                                            {% endfor %}
                                        {% endif %}
                                    {% endfor %}
                                </td>
                            </tr>
                        {% endif %}

                        {% if 'two' in audit_dic %}
                            <tr style="width: 100%;">
                                <td style="width: 15%;height: 150px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">
                                    医院办公室
                                </td>
                                <td style="width: 85%;height: 150px;border: #cccccc solid 1px;border-left: none;border-top: none;">
                                    {% for k,v in audit_dic.items %}
                                        {% if k == 'two' %}
                                            {% for item in v %}
                                                {% if item.state != 'unaudit' %}
                                                    <div style="width: 100%;line-height: 20px;position: relative;">
                                                        <span>{{ item.state_display }}</span>
                                                        <span style="margin-left: 3%">{{ item.audit_note }}</span>
                                                    </div>
                                                    <div>
                                                        <img src="{{ item.signature_picture }}" alt=""
                                                             style="width: 150px; height: 60px;">
                                                    </div>
                                                    <div style="text-align: right;color: #0b0b0b;">{{ item.audit_time }}</div>
                                                {% endif %}
                                            {% endfor %}
                                        {% endif %}
                                    {% endfor %}
                                </td>
                            </tr>
                        {% endif %}
                    </table>
                </div>
            </div>

        </div>
    </div>

    <div id="LH" style="width: 100%;height: 94%;background: white;display: none;">
        <div style="display: inline-block;width: 20%;vertical-align: top;height: 99%">
            <div style="width: 100%;height: 40px;background: #c8cbcf;padding-left: 2%;line-height: 40px;color: #0c6fd9;">
                附件
            </div>
            <div id="yt_zhengwen" style="width: 100%;">
                {% for item in file_list %}
                    <div><a href="#" class="a_tag_cla" onclick="chage_yulan(this, '{{ item.file_path }}')">{{ item.file_name }}</a></div>
                {% endfor %}
            </div>

        </div>
        <div style="display: inline-block;width: 78%;vertical-align: top;height: 99%;text-align: center;" id="fujian">
            {% if 'jpg' in file_path or 'JPG' in file_path or 'JPEG' in file_path or 'jpeg' in file_path or 'PNG' in file_path or 'png' in file_path %}
                <img src="{{ file_path }}" alt="" style="width: 800px;height: 100%;">
            {% else %}
                <embed id="embed_file" src="{{ file_path }}" type="application/pdf" style="width: 100%;height: 100%;">
            {% endif %}
        </div>
    </div>

    <div id="lct" style="width: 100%;height: 94%;background: white;display: none;">
        <div style="width: 100%;height: 40%;text-align: center;margin: 20% auto;">
            <div style="display: inline-block;vertical-align: top;cursor: pointer;text-align: center;">
                <div style="text-align: center;color: #0d8ddb;">
                    ({{ obj.create_people.real_name }})<br>
                    发起人
                </div>
                <div style="width: 50px;height: 25px;border-radius: 3px;background: #0d8ddb;color: white;text-align: center;display: inline-block;font-size: 12px;line-height: 25px;">
                    start
                </div>
            </div>

            {% if 'one' in flow_dict %}
                {% for k,v in flow_dict.items %}
                    {% if k == 'one' %}
                        <div style="display: inline-block;border: {% if v.apply == 'true' %} #0d8ddb {% else %} #cfcfcf {% endif %} solid 1px;width: 120px;vertical-align: bottom;margin-bottom: 12px;"></div>
                        <div style="display: inline-block;vertical-align: top;cursor: pointer;text-align: center;">
                            <div style="text-align: center;{% if v.apply == 'true' %} color: #0d8ddb; {% endif %}">
                                ({{ v.apply_people }})<br>
                                分管领导
                            </div>
                            <div style="width: 25px;height: 25px;border-radius: 50%;{% if v.apply == 'true' %} background: #0d8ddb; {% else %} background: #cfcfcf; {% endif %}color: white;text-align: center;display: inline-block;font-size: 12px;line-height: 25px;">
                                {{ v.sear }}
                            </div>
                        </div>
                    {% endif %}
                {% endfor %}
            {% endif %}

            {% if 'two' in flow_dict %}
                {% for k,v in flow_dict.items %}
                    {% if k == 'two' %}
                        <div style="display: inline-block;border: {% if v.apply == 'true' %} #0d8ddb {% else %} #cfcfcf {% endif %} solid 1px;width: 120px;vertical-align: bottom;margin-bottom: 12px;"></div>
                        <div style="display: inline-block;vertical-align: top;cursor: pointer;text-align: center;">
                            <div style="text-align: center;{% if v.apply == 'true' %} color: #0d8ddb; {% endif %}">
                                ({{ v.apply_people }})<br>
                                医院办公室
                            </div>
                            <div style="width: 25px;height: 25px;border-radius: 50%;{% if v.apply == 'true' %} background: #0d8ddb; {% else %} background: #cfcfcf; {% endif %}color: white;text-align: center;display: inline-block;font-size: 12px;line-height: 25px;">
                                {{ v.sear }}
                            </div>
                        </div>
                    {% endif %}
                {% endfor %}
            {% endif %}

            <div style="display: inline-block;border: #0d8ddb solid 1px;width: 120px;vertical-align: bottom;margin-bottom: 12px;"></div>
            <div style="display: inline-block;vertical-align: top;cursor: pointer;text-align: center;">
                <div style="text-align: center;color: #0d8ddb;">
                    <span style="visibility: hidden;">({{ obj.apply_user.real_name }})</span><br>
                    结束
                </div>
                <div style="width: 50px;height: 25px;border-radius: 3px;background: #0d8ddb;color: white;text-align: center;display: inline-block;font-size: 12px;line-height: 25px;">
                    ending
                </div>
            </div>
        </div>
    </div>
{% endblock %}


{% block script %}
    <script type="text/javascript" src="../../static/public_file/js/ApprovalBox.js"></script>
    <script>
        window.onload = function () {
            document.getElementById("Announcement-economy").className = "add_class";
            document.getElementById("inform").className = "add-nav-active";
        };

        function change_mind(ele_id) {
            if (ele_id === "DW") {
                document.getElementById("DW").style.display = "inline-block";
                document.getElementById("DW_tag").className = "tab_top top_tag";
                document.getElementById("LH_tag").className = "tab_top";
                document.getElementById("LH").style.display = "none";
                document.getElementById("lct_tag").className = "tab_top";
                document.getElementById("lct").style.display = "none";
            } else if (ele_id === "LH") {
                document.getElementById("LH").style.display = "inline-block";
                document.getElementById("LH_tag").className = "tab_top top_tag";
                document.getElementById("DW_tag").className = "tab_top";
                document.getElementById("DW").style.display = "none";
                document.getElementById("lct_tag").className = "tab_top";
                document.getElementById("lct").style.display = "none";
            }else {
                document.getElementById("lct").style.display = "inline-block";
                document.getElementById("lct_tag").className = "tab_top top_tag";
                document.getElementById("DW_tag").className = "tab_top";
                document.getElementById("DW").style.display = "none";
                document.getElementById("LH_tag").className = "tab_top";
                document.getElementById("LH").style.display = "none";
            }
        }


        function summit_data(approve) {
            var present_id = window.location.href.split("id=")[1].replace("#", '');
            var audit_note = document.getElementById("opinion_detail").value;
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/announcements/audit_notice");
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
            xhr.send("id="+present_id+"&state="+String(approve)+"&audit_note="+String(audit_note));
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200){
                            alert("审批成功");
                            window.location.href="/personal-center/process_management.html?type=我的待办&folw_type=公告管理&folw=通知公告&page=1&page_size=20&wd=";
                        }else {
                            alert(JsonDate["message"]);
                        }
                    }
                }
            };
        }

        function page_zhanshi() {
            document.getElementById('page_one').style.display = 'inline-block';
        }

        function page_yincang() {
            document.getElementById('page_one').style.display = 'none';
        }
    </script>
{% endblock %}
